package cn.rkylin.oms.system.shop.service;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageInfo;

import cn.rkylin.core.service.ApolloService;
import cn.rkylin.oms.system.shop.dao.IShopDAO;
import cn.rkylin.oms.system.shop.domain.Shop;
import cn.rkylin.oms.system.shop.vo.ShopVO;

/**
 * 店铺管理服务实现
 * 
 * @author wangxiaoyi
 * @version 1.0
 * @created 13-1月-2017 09:11:15
 */
@Service("shopService")
public class ShopServiceImpl extends ApolloService implements IShopService {
	/**
	 * 店铺数据访问
	 */
	@Autowired
	private IShopDAO shopDAO;

	public void setShopDAO(IShopDAO shopDAO) {
        this.shopDAO = shopDAO;
    }

    public IShopDAO getShopDAO() {
		return shopDAO;
	}

	/**
	 * 构造函数
	 */
	public ShopServiceImpl() {

	}
	/**
	 * 修改店铺
	 * 
	 * @param shopVO
	 */
	@Transactional
	@CachePut(value = "shop", key = "T(String).valueOf('shop:').concat(#shopVO.shopId)")
	public ShopVO update(ShopVO shopVO) throws Exception {
		Shop shop = new Shop();
		BeanUtils.copyProperties(shopVO, shop);
		shopDAO.update(shop);
		return shopVO;
	}

    /**
     * 查询店铺列表.
     * @see cn.rkylin.oms.system.shop.service.IShopService#findByWhere(cn.rkylin.oms.system.shop.vo.ShopVO)
     */
    @Override
    public ShopVO findById(String shopId) throws Exception {
        return shopDAO.findById(shopId);
    }
}